﻿@model Resto.CostControl.Core.DishOrderItem
@{
    ViewBag.Title = "选择品名";
    Layout = "~/Views/Shared/_LayoutForm.cshtml"; 
}
@using (Html.AjaxBeginForm())
{ 
    <div class="pageFormContent" style="width: 600px">
        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.OrderId)
        @Html.HiddenFor(model => model.DishId)
        @Html.HiddenFor(model => model.SiteId)
        @Html.HiddenFor(model => model.Code)
        @Html.DWZTextBoxFor(model => model.Name, @Url.GridLink("setGroup", "选择", "SelectDish()", new { style = "display: block; float: left; padding-top:5px;" }), new { style = "width:100px" }).ReadOnly(true).Required()
        @Html.DWZTextBoxFor(model => model.Count, new { onchange = "Javascript:CalaTotal()" }).Number()
        @Html.DWZDropDownListFor(model => model.Category, "DishType")
        @Html.DWZDropDownListFor(model => model.Stall, "StallType").Required()
        @Html.DWZDropDownListFor(model => model.MealType, "MealType").Required()
        @Html.DWZDateFor(model => model.Date).Required()
        @Html.DWZTextBoxFor(model => model.DishCost, new { onchange = "Javascript:CalaTotalCost()" }).Number()
        @Html.DWZTextBoxFor(model => model.TotalCost).Number().ReadOnly(true)
        @Html.DWZTextBoxFor(model => model.DishPrice, new { onchange = "Javascript:CalaTotalPrice()" }).Number()
        @Html.DWZTextBoxFor(model => model.TotalPrice).Number().ReadOnly(true)
        @Html.DWZTextAreaFor(model => model.Remark)
    </div>
}
@Html.FormBar()
<script type="text/javascript">
    function SelectDish(e) {
        OpenModelWindow('@Url.Action("LookupDish", "Dish")?Date=' + $('#Date').val(), { caption: "选择菜肴", width: 840, height: 400, onclose: function (data) {
            if (data) {
                $("#DishId").val(data.DishId);
                $("#Code").val(data.Code);
                $("#Name").val(data.Name);
                $("#Category").val(data.Category);
                $("#DishCost").val(data.DishCost);
                $("#DishPrice").val(data.DishPrice);
            }
        }
        });
}
function CalaTotal() {
    CalaTotalCost();
    CalaTotalPrice();
}

function CalaTotalCost() {
    var count = $("#Count").val();
    var dishcose = $("#DishCost").val();
    $("#TotalCost").val(parseFloat(count) * parseFloat(dishcose));
}

function CalaTotalPrice() {
    var count = $("#Count").val();
    var dishprice = $("#DishPrice").val();
    $("#TotalPrice").val(parseFloat(count) * parseFloat(dishprice));
}

</script>
